package com.loong.user.handler;

import com.loong.common.domain.BaseQuery;
import com.loong.common.domain.Pager;
import com.loong.common.utils.TransformUtils;
import com.loong.user.business.ManageDepartmentBusiness;
import com.loong.user.common.backend.param.manageDepartmentParam;
import com.loong.user.common.backend.param.manageDepartmentQueryParam;
import com.loong.user.common.backend.result.ManageDepartmentResult;
import com.loong.user.model.ManageDepartment;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;

/**
 * @Description: 后台系统部门服务
 * @Author: hzp
 * @Date: 2020-10-16 11:05
 */
@Component
public class ManageDepartmentHandler {
    @Resource
    private ManageDepartmentBusiness manageDepartmentBusiness;

    /**
     * 保存后台系统部门
     * @param param
     */
    public void save(manageDepartmentParam param){
        manageDepartmentBusiness.save(TransformUtils.transform(param, ManageDepartment.class));
    }

    /**
     * 更新后台系统部门
     * @param param
     */
    public void update(manageDepartmentParam param){
        manageDepartmentBusiness.updateByPrimaryKeySelective(TransformUtils.transform(param, ManageDepartment.class));
    }

    /**
     *根据id删除后台系统部门
     * @param id
     */
    public void deleteById(Long id){
        manageDepartmentBusiness.deleteById(id);
    }

    /**
     * 分页查询
     * @param baseQuery
     * @param param
     * @return
     */
    public Pager<ManageDepartmentResult> pageQuery(BaseQuery baseQuery, manageDepartmentQueryParam param){
        Pager<ManageDepartment> manageApisPager = manageDepartmentBusiness.pageQuery(baseQuery, () -> manageDepartmentBusiness.query(param));
        return TransformUtils.transformPage(manageApisPager, ManageDepartmentResult.class);
    }
}
